﻿using System;
using System.Collections.Generic;
using System.Linq;
using LBoL.Base;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Battle.Interactions;
using LBoL.Core.Cards;
using LBoLEntitySideloader.Attributes;
using ProbeMod.Cards.Template;
using ProbeMod.StatusEffects;

namespace ProbeMod.Cards
{
    public sealed class ProbeSwiftRetributionDef : ProbeCardTemplate
    {
        public override CardConfig MakeConfig()
        {
            var config = GetCardDefaultConfig();

            config.Rarity = Rarity.Common;
            config.Type = CardType.Skill;
            config.TargetType = TargetType.Nobody;
            config.Colors = new List<ManaColor>() { ManaColor.Blue };

            config.Cost = new ManaGroup() { Blue = 1,Any = 1 };
            config.UpgradedCost = new ManaGroup() { Blue = 1 };

            config.Value1 = 2;
            
            config.Keywords = Keyword.Exile | Keyword.Initial;
            config.UpgradedKeywords = Keyword.Exile | Keyword.Initial;

            config.RelativeCards = new List<string>() { "ProbeZealotCharge", "ProbeStalker", "ProbePylon" };
            config.UpgradedRelativeCards = new List<string>() { "ProbeZealotCharge", "ProbeStalker", "ProbePylon" };

            config.Index = CardIndexGenerator.GetUniqueIndex(config);
            return config;
        }
    }

    /// <summary>
    /// 即时正义
    /// </summary>
    [EntityLogic(typeof(ProbeSwiftRetributionDef))]
    public sealed class ProbeSwiftRetribution : ProbeCard
    {
        protected override IEnumerable<BattleAction> Actions(UnitSelector selector, ManaGroup consumingMana, Interaction precondition)
        {
            var card = Library.CreateCard<ProbePylon>(IsUpgraded);
            card.Summon();
            yield return new AddCardsToHandAction(card);

            // 下回合给俩
            yield return BuffAction<ProbeNextTurnZealotSe>(level:Value1);
            yield return BuffAction<ProbeNextTurnStalkerSe>(level: Value1);
        }
    }
}
